<template>
	<view class="memberSalesRecord">
		<headerVue ref="header" @changeIndex="changeHeaderIndex" @dateConfirm="dateConfirm"></headerVue>
		<!-- <view class="tab">
			<view v-for="(item,index) in tabList" :key="index" class="tabIndex" @click="changeIndex(index)">
				<view :class="activeIndex == index ?'tabsize1':'tabsize2'">
					{{item}}
				</view>
				<view class="active">
					<view class="empty" v-if="activeIndex == index">

					</view>
				</view>
			</view>
		</view> -->
		<scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="scrolltolower">
			<view class="comlumn_box" v-if="memberList.length">
				<view v-for="(item,index) in memberList" :key="index" class="Item">
					<view class="top">
						<view class="user">
							<image :src="item.user_info.avatar" mode="aspectFill" class="uimg"></image>
							<view class="name">
								{{item.user_info.nickname}}
							</view>
						</view>
						<view class="time">
							{{item.time}}
						</view>
					</view>
					<view class="bottom">
						<image :src="item.course_info.image" mode="aspectFill" class="memberCard"></image>
						<view class="right-box">
							<view class="right_top">
								<view class="title1">
									{{item.course_info.title}}
								</view>
								<view class="red_box">
									<view class="unit">
										￥
									</view>
									<view class="price">
										{{item.cost}}
									</view>
								</view>
							</view>
							<view class="top2">
								<view class="top_left">
									进度
								</view>
								<view class="size3">
									{{item.that_str}}
								</view>
							</view>
							<view class="top2">
								<view class="top_left">
									场地
								</view>
								<view class="size3">
									{{item.course_info.shop_name}}
								</view>
							</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="status" />
			</view>
			<empty v-else :content="'业绩'"></empty>
		</scroll-view>
	</view>
</template>

<script>
	import headerVue from './components/header.vue'
	import empty from './components/empty.vue'
	import {
		performance
	} from '@/api/coach.js'
	export default {
		components: {
			headerVue,
			empty
		},
		data() {
			return {
				query: {
					date: '',
					form: 'day',
					page: 1
				},
				popupShow: false,
				// tabList: [
				// 	'全部',
				// 	'待结算',
				// 	'已结算',
				// 	'已提现'
				// ],
				// activeIndex: 0,
				memberList: [],
				status: 'loadmore', //当前状态
			}
		},
		mounted() {
			this.query.date = this.$refs.header.day
			console.log('query', this.query);
			this.getperformance()
		},
		methods: {
			scrolltolower(){
				this.query.page++
				this.getperformance()
			},
			getperformance() {
				performance(this.query).then(({
					data: res
				}) => {
					console.log('res', res);
					if (res.code == 1) {
						const list = []
						this.status = 'loading'
						if (this.query.page > res.data.all_page) {
							console.log('nomore');
							this.status = 'nomore'
							return false
						} else {
							console.log('more');
							this.status = 'more'
							this.memberList = this.memberList.concat(res.data.list)
						}

						console.log('memberList', this.memberList);
					}
				})
			},
			toggle() {
				console.log(11);
				this.popupShow = true
			},
			// changeIndex(index) {
			// 	this.activeIndex = index
			// },
			changeHeaderIndex(e) {
				this.query.form = e == 0 ? 'day' : e == 1 ? 'month' : 'year'
				this.query.date = this.$refs.header.day
				console.log('form', this.query.form);
				this.query.page = 1
				this.memberList = []
				this.getperformance()
			},
			dateConfirm(e, data) {
				console.log('e321', data);
				this.query.date = data
				this.query.page = 1
				this.memberList = []
				this.getperformance()
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #e9e9e9;
	}

	.memberSalesRecord {
		display: flex;
		flex-direction: column;
		align-items: center;

		.tab {
			width: 750rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-around;
			background: #ffffff;

			.tabIndex {
				display: flex;
				flex-direction: column;
				align-items: center;

				.tabsize1 {
					height: 44rpx;
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC-Heavy;
					font-weight: 800;
					text-align: center;
					color: #73F0EA;
					letter-spacing: 0.7rpx;

				}

				.tabsize2 {
					height: 44rpx;
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC-Regular;
					font-weight: 400;
					text-align: center;
					color: #666666;
					letter-spacing: 0.7rpx;

				}

				.active {
					margin-top: 12rpx;
					width: 44rpx;
					height: 8rpx;

					.empty {
						width: 100%;
						height: 100%;
						background: #73F0EA;
						border: 2rpx solid rgba(0, 0, 0, 0.00);
						border-radius: 2rpx;
					}
				}
			}
		}

		.scroll-Y {
			width: 100%;
			height: 88vh;

			.comlumn_box {
				display: flex;
				flex-direction: column;
				align-items: center;
				padding-top: 20rpx;

				.Item {
					width: 702rpx;
					height: 256rpx;
					background: #ffffff;
					border-radius: 16rpx;
					padding: 20rpx 24rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					margin-bottom: 20rpx;

					.top {
						width: 100%;
						padding-bottom: 22rpx;
						display: flex;
						flex-direction: row;
						align-items: center;

						.user {
							flex: 1;
							display: flex;
							flex-direction: row;
							align-items: center;

							.uimg {
								width: 48rpx;
								height: 48rpx;
								background: #f6f6f6;
								border-radius: 50%;
								margin-right: 14rpx;
							}

							.name {
								font-size: 28rpx;
								font-family: PingFang SC, PingFang SC-Bold;
								font-weight: 700;
								text-align: left;
								color: #333333;
							}
						}

						.time {
							font-size: 24rpx;
							font-family: PingFang SC, PingFang SC-Medium;
							font-weight: 500;
							color: #999999;
						}
					}

					.bottom {
						// padding-top: 26rpx;
						display: flex;
						flex-direction: row;
						
						width: 100%;

						.memberCard {
							width: 160rpx;
							height: 120rpx;
							margin-right: 20rpx;
						}

						.right-box {
							display: flex;
							flex-direction: column;
							justify-content: space-between;
							flex: 1;

							.right_top {
								display: flex;
								flex-direction: row;
								align-items: center;

								.title1 {
									font-size: 32rpx;
									font-family: PingFang SC, PingFang SC-Bold;
									font-weight: 700;
									text-align: left;
									color: #333333;
									flex: 1;
								}

								.red_box {
									display: flex;
									flex-direction: row;
									align-items: baseline;

									.unit {
										font-size: 24rpx;
										font-family: PingFang SC, PingFang SC-Bold;
										font-weight: 700;
										color: #f37364;
									}

									.price {
										font-size: 32rpx;
										font-family: DIN, DIN-Bold;
										font-weight: 700;
										text-align: left;
										color: #f37364;
									}
								}
							}

							.top2 {
								display: flex;
								flex-direction: row;
								align-items: center;

								.top_left {
									flex: 1;
									font-size: 24rpx;
									font-family: PingFang SC, PingFang SC-Regular;
									font-weight: 400;
									color: #000000;
								}

								.size3 {
									font-size: 24rpx;
									font-family: PingFang SC, PingFang SC-Regular;
									font-weight: 400;
									color: #666666;
								}
							}
						}
					}
				}
			}
		}
	}
</style>